package com.wpl.fastec.latte.core.activities;

import android.os.Bundle;
import android.widget.FrameLayout;

import androidx.annotation.Nullable;

import com.wpl.fastec.latte.core.R;
import com.wpl.fastec.latte.core.fragments.LatteFragment;

import me.yokeyword.fragmentation.SupportActivity;

public abstract  class ProxyActivity extends SupportActivity {

    public abstract LatteFragment setRootFragment();

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initContainer(savedInstanceState);
    }

    private void initContainer(@Nullable Bundle savedInstanceState){
        final FrameLayout container = new FrameLayout(this);
        container.setId(R.id.fragment_container);
        setContentView(container);
        //第一次加载
        if (savedInstanceState == null) {
            loadRootFragment(R.id.fragment_container,setRootFragment());
        }

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        System.gc();
        System.runFinalization();
    }
}
